# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self.dbuspath = dbuspath
self.dest_uri = dest_uri
self.source_uri = None
self.wydbus_reference = wydbus_reference
self.last_size = config.max_size_for_timeshift
self.rec_start = wydbus_reference.method('start', 's', 'i')
self.rec_stop = wydbus_reference.method('stop', '', 'i')
self.set_max_size = wydbus_reference.method('set_max_size', 't', 'i')
self.protect_segment = wydbus_reference.method('protect_segment', 't', 'i')
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776c3ec>}
nname: 118
n 118(None)[timestep('recorder instance: start')
log.debug('rec_start result= ' + str(res))
]:
	i: 59(), 88(), 116(AE)
	o: 

nname: 116
n 116(None)[]:
	i: 78(f)
	o: 118(AE)

nname: 88
n 88(None)[#, e
log.debug(str(e))
]:
	i: 78(t)
	o: 118()

nname: 78
n 78(<dummy_ex3> EXC_MATCH BaseException)[]:
	i: 0(except)
	o: 88(t), 116(f)

nname: 59
n 59(None)[res = self.rec_start(source_uri)
]:
	i: 0(try)
	o: 118()

nname: 0
n 0(None)[res = 'failed'
self.source_uri = source_uri
log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
timestep('startRec init')
]:
	i: 
	o: 59(try), 78(except)

nname: 78
n 78(None)[except BaseException, e:
	log.debug(str(e))
timestep('recorder instance: start')
log.debug('rec_start result= ' + str(res))
]:
	i: 0()
	o: 

nname: 0
n 0(None)[res = 'failed'
self.source_uri = source_uri
log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
timestep('startRec init')
try:
	res = self.rec_start(source_uri)
]:
	i: 
	o: 78()

nname: 0
n 0(None)[res = 'failed'
self.source_uri = source_uri
log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
timestep('startRec init')
try:
	res = self.rec_start(source_uri)
except BaseException, e:
	log.debug(str(e))
timestep('recorder instance: start')
log.debug('rec_start result= ' + str(res))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776c2ec>}
nname: 95
n 95(None)[timestep('recorder instance: stop')
log.debug('rec_stop result= ' + str(res))
]:
	i: 39(), 65(), 93(AE)
	o: 

nname: 93
n 93(None)[]:
	i: 55(f)
	o: 95(AE)

nname: 65
n 65(None)[#, e
log.debug(str(e))
]:
	i: 55(t)
	o: 95()

nname: 55
n 55(<dummy_ex3> EXC_MATCH BaseException)[]:
	i: 0(except)
	o: 65(t), 93(f)

nname: 39
n 39(None)[res = self.rec_stop()
]:
	i: 0(try)
	o: 95()

nname: 0
n 0(None)[log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
timestep('stopRec init')
res = 'failed'
]:
	i: 
	o: 39(try), 55(except)

nname: 55
n 55(None)[except BaseException, e:
	log.debug(str(e))
timestep('recorder instance: stop')
log.debug('rec_stop result= ' + str(res))
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
timestep('stopRec init')
res = 'failed'
try:
	res = self.rec_stop()
]:
	i: 
	o: 55()

nname: 0
n 0(None)[log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
timestep('stopRec init')
res = 'failed'
try:
	res = self.rec_stop()
except BaseException, e:
	log.debug(str(e))
timestep('recorder instance: stop')
log.debug('rec_stop result= ' + str(res))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776cc8c>}
nname: 0
n 0(None)[log.info('ExternalRecorde called: setMaxRecSize: ' + str(int(size)))
timestep('setMaxRecSize init')
self.last_size = int(size)
self.set_max_size(int(size))
timestep('recorder instance: set_max_size')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7766fac>}
nname: 6
n 6(None)[def __init__(self, dest_uri, wydbus_reference, dbuspath):
	self.dbuspath = dbuspath
	self.dest_uri = dest_uri
	self.source_uri = None
	self.wydbus_reference = wydbus_reference
	self.last_size = config.max_size_for_timeshift
	self.rec_start = wydbus_reference.method('start', 's', 'i')
	self.rec_stop = wydbus_reference.method('stop', '', 'i')
	self.set_max_size = wydbus_reference.method('set_max_size', 't', 'i')
	self.protect_segment = wydbus_reference.method('protect_segment', 't', 'i')
	return None

def startRec(self, source_uri):
	res = 'failed'
	self.source_uri = source_uri
	log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
	timestep('startRec init')
	try:
		res = self.rec_start(source_uri)
	except BaseException, e:
		log.debug(str(e))
	timestep('recorder instance: start')
	log.debug('rec_start result= ' + str(res))

def stopRec(self):
	log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
	timestep('stopRec init')
	res = 'failed'
	try:
		res = self.rec_stop()
	except BaseException, e:
		log.debug(str(e))
	timestep('recorder instance: stop')
	log.debug('rec_stop result= ' + str(res))

def setMaxRecSize(self, size):
	log.info('ExternalRecorde called: setMaxRecSize: ' + str(int(size)))
	timestep('setMaxRecSize init')
	self.last_size = int(size)
	self.set_max_size(int(size))
	timestep('recorder instance: set_max_size')

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb776686c>}
nname: 0
n 0(None)[self.dbuspath = dbuspath
self.dest_uri = dest_uri
self.wydbus_reference = wydbus_reference
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7766e0c>}
nname: 0
n 0(None)[log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + source_uri)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7766ecc>}
nname: 0
n 0(None)[log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri + 'source => ' + source_uri)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7766eec>}
nname: 0
n 0(None)[log.info('ExternalRecorde called: setMaxRecSize: ' + str(size))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7766e8c>}
nname: 6
n 6(None)[def __init__(self, dest_uri, wydbus_reference, dbuspath):
	self.dbuspath = dbuspath
	self.dest_uri = dest_uri
	self.wydbus_reference = wydbus_reference

def startRec(self, source_uri):
	log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + source_uri)

def stopRec(self):
	log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri + 'source => ' + source_uri)

def setMaxRecSize(self, size):
	log.info('ExternalRecorde called: setMaxRecSize: ' + str(size))

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7766a0c>}
nname: 0
n 0(None)[from logger import log
from peewee.analyse import timestep
from config import *
class ExternalRecorder(object):
	def __init__(self, dest_uri, wydbus_reference, dbuspath):
		self.dbuspath = dbuspath
		self.dest_uri = dest_uri
		self.source_uri = None
		self.wydbus_reference = wydbus_reference
		self.last_size = config.max_size_for_timeshift
		self.rec_start = wydbus_reference.method('start', 's', 'i')
		self.rec_stop = wydbus_reference.method('stop', '', 'i')
		self.set_max_size = wydbus_reference.method('set_max_size', 't', 'i')
		self.protect_segment = wydbus_reference.method('protect_segment', 't', 'i')
		return None

	def startRec(self, source_uri):
		res = 'failed'
		self.source_uri = source_uri
		log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
		timestep('startRec init')
		try:
			res = self.rec_start(source_uri)
		except BaseException, e:
			log.debug(str(e))
		timestep('recorder instance: start')
		log.debug('rec_start result= ' + str(res))

	def stopRec(self):
		log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
		timestep('stopRec init')
		res = 'failed'
		try:
			res = self.rec_stop()
		except BaseException, e:
			log.debug(str(e))
		timestep('recorder instance: stop')
		log.debug('rec_stop result= ' + str(res))

	def setMaxRecSize(self, size):
		log.info('ExternalRecorde called: setMaxRecSize: ' + str(int(size)))
		timestep('setMaxRecSize init')
		self.last_size = int(size)
		self.set_max_size(int(size))
		timestep('recorder instance: set_max_size')



class DummyExternalRecorder(object):
	def __init__(self, dest_uri, wydbus_reference, dbuspath):
		self.dbuspath = dbuspath
		self.dest_uri = dest_uri
		self.wydbus_reference = wydbus_reference

	def startRec(self, source_uri):
		log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + source_uri)

	def stopRec(self):
		log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri + 'source => ' + source_uri)

	def setMaxRecSize(self, size):
		log.info('ExternalRecorde called: setMaxRecSize: ' + str(size))



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7760d2c>}
from logger import log
from peewee.analyse import timestep
from config import *
class ExternalRecorder(object):
	def __init__(self, dest_uri, wydbus_reference, dbuspath):
		self.dbuspath = dbuspath
		self.dest_uri = dest_uri
		self.source_uri = None
		self.wydbus_reference = wydbus_reference
		self.last_size = config.max_size_for_timeshift
		self.rec_start = wydbus_reference.method('start', 's', 'i')
		self.rec_stop = wydbus_reference.method('stop', '', 'i')
		self.set_max_size = wydbus_reference.method('set_max_size', 't', 'i')
		self.protect_segment = wydbus_reference.method('protect_segment', 't', 'i')
		return None

	def startRec(self, source_uri):
		res = 'failed'
		self.source_uri = source_uri
		log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + self.source_uri)
		timestep('startRec init')
		try:
			res = self.rec_start(source_uri)
		except BaseException, e:
			log.debug(str(e))
		timestep('recorder instance: start')
		log.debug('rec_start result= ' + str(res))

	def stopRec(self):
		log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri)
		timestep('stopRec init')
		res = 'failed'
		try:
			res = self.rec_stop()
		except BaseException, e:
			log.debug(str(e))
		timestep('recorder instance: stop')
		log.debug('rec_stop result= ' + str(res))

	def setMaxRecSize(self, size):
		log.info('ExternalRecorde called: setMaxRecSize: ' + str(int(size)))
		timestep('setMaxRecSize init')
		self.last_size = int(size)
		self.set_max_size(int(size))
		timestep('recorder instance: set_max_size')



class DummyExternalRecorder(object):
	def __init__(self, dest_uri, wydbus_reference, dbuspath):
		self.dbuspath = dbuspath
		self.dest_uri = dest_uri
		self.wydbus_reference = wydbus_reference

	def startRec(self, source_uri):
		log.info('ExternalRecorder called: startRec dest => ' + self.dest_uri + 'source => ' + source_uri)

	def stopRec(self):
		log.info('ExternalRecorder called: stopRec dest => ' + self.dest_uri + 'source => ' + source_uri)

	def setMaxRecSize(self, size):
		log.info('ExternalRecorde called: setMaxRecSize: ' + str(size))



